home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / menuEditorSetup.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.8 KB  |  155 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. // $Source: /vobs/aw/Maya/src/SharedUI/UI/scripts/menuEditorSetup.mel $
  21. //
  22. // $Locker:  $
  23. //
  24. // $Author: bkramer $
  25. // $Revision: /main/7 $
  26. // $Date: 2000/01/27 14:29:36 $
  27. //
  28. //
  29. // Original Author:    mm
  30. //
  31. //  Description:
  32. //    This file contains procedures associated with
  33. //    the drag-n-drop Marking Menus editor.
  34. //
  35.  
  36. // ======================== These routines are used internally by the MM Editor. ========================
  37.  
  38. global proc string generateMarkingMenuEditorFilenameFromAnnotation(string $annotation) {
  39.  
  40.     return ("menu_" + $annotation);
  41. }
  42.  
  43. global proc int isMenuRegisteredWithMenuEditor(string $annotation) {
  44.  
  45.     if (`optionVar -exists markingMenuEditorAnnotations`) {
  46.         string $annotationArray[] = `optionVar -q markingMenuEditorAnnotations`;
  47.         int $j;
  48.         for ($j = size($annotationArray) - 1; $j >= 0; --$j)
  49.             if ($annotationArray[$j] == $annotation)
  50.                 return true;
  51.     }
  52.  
  53.     return false;
  54. }
  55.  
  56. global proc int registerMenuWithMenuEditor(string $fileName, string $annotation) {
  57.  
  58.     // Ensure that the user respects the
  59.     // naming convention used in this file.
  60.     //
  61.     string $fullName;
  62.     
  63.     $fullName = `internalVar -userMarkingMenuDir` + $fileName;
  64.  
  65.     if (
  66.         // Don't register the menu if it doesn't respect the naming conventions.
  67.         //
  68.         $fileName != generateMarkingMenuEditorFilenameFromAnnotation($annotation)
  69.  
  70.         // Don't register the menu if the script to create it doesn't exist.
  71.         //
  72.     ||    (!`exists $fullName` && !`exists $fileName`)
  73.  
  74.         // Don't register the menu if another menu is already registered with the same annotation.
  75.         //
  76.     ||    isMenuRegisteredWithMenuEditor($annotation)
  77.     ) {
  78.         return 0;   // failure
  79.     }
  80.  
  81.  
  82.     optionVar
  83.         -stringValueAppend markingMenuEditorFilenames $fileName
  84.         -stringValueAppend markingMenuEditorAnnotations $annotation
  85.         -intValueAppend markingMenuEditorDisplayAsMMFlags 1
  86.         -intValueAppend markingMenuEditorIsNamedCommandFlags 0;
  87.  
  88.     return 1;   // success
  89. }
  90.  
  91. // $region is one of "N", "S", "E", "W", or "C" ("C" for center)
  92. // $button is one of 1, 2, 3, for Left, Middle, Right - respectively
  93. //
  94. global proc string generateNameOfHotBoxOptionVar(string $region, int $button) {
  95.  
  96.     return ("nameOfHotBox" + $region + $button + "MarkingMenu");
  97. }
  98.  
  99. // ======================== These routines are a public interface to the hotBox scripts. ========================
  100.  
  101. global proc int isHotBoxMenuDefined(string $region, int $button) {
  102.  
  103.     string $nameOfOptionVar = generateNameOfHotBoxOptionVar($region,$button);
  104.  
  105.     return (`optionVar -exists $nameOfOptionVar`);
  106. }
  107.  
  108. global proc string getScriptNameForHotBoxMenu(string $region, int $button) {
  109.  
  110.     string $nameOfOptionVar = generateNameOfHotBoxOptionVar($region,$button);
  111.  
  112.     if (`optionVar -exists $nameOfOptionVar`) {
  113.         string $annotation = `optionVar -q $nameOfOptionVar`;
  114.         if ($annotation == "")
  115.             return "";   // The menu is "empty".
  116.         else {
  117.             string $filename = generateMarkingMenuEditorFilenameFromAnnotation($annotation);
  118.  
  119.             string $filename2 = `internalVar -userMarkingMenuDir` + $filename;
  120.  
  121.             // Check if the file exists.
  122.             //
  123.             if (`exists $filename2`)
  124.                 return $filename2;
  125.             else if (`exists $filename`)
  126.                 return $filename;
  127.             else
  128.                 return "";
  129.         }
  130.     }
  131.     else
  132.         return "";
  133. }
  134.  
  135. global proc registerHotBoxMenuWithMenuEditor(string $fileName, string $annotation, string $region, int $isLeft, int $isMiddle, int $isRight) {
  136.  
  137.     if (registerMenuWithMenuEditor($fileName, $annotation) == 0)
  138.         return;   // failure
  139.  
  140.     string $nameOfOptionVar;
  141.  
  142.     if ($isLeft) {
  143.         $nameOfOptionVar = generateNameOfHotBoxOptionVar($region,1);
  144.         optionVar -stringValue $nameOfOptionVar $annotation;
  145.     }
  146.     if ($isMiddle) {
  147.         $nameOfOptionVar = generateNameOfHotBoxOptionVar($region,2);
  148.         optionVar -stringValue $nameOfOptionVar $annotation;
  149.     }
  150.     if ($isRight) {
  151.         $nameOfOptionVar = generateNameOfHotBoxOptionVar($region,3);
  152.         optionVar -stringValue $nameOfOptionVar $annotation;
  153.     }
  154. }
  155.